/**
 * 菜单是否显示操作按钮（根据用户权限）
 **/
import { useRoute } from 'vue-router'

function isShowBtn(btnName) {
  const route = useRoute()
  let url = route.path.replace('/', '')
  let btnArr = localStorage.getItem('menuList') ? JSON.parse(localStorage.getItem('menuList')) : []
  let isshow = false
  for (let i = 0; i < btnArr.length; i++) {
    let item = btnArr[i]
    if (item.url === url && item.menuPermission && item.menuPermission.includes(btnName)) {
      isshow = true
      break
    }
  }
  return isshow
}

export { isShowBtn }
